gitlab () {
    # gitlab
    DOCKER_CMD="docker run -d \
        -p 8011:443 \
        -p 8012:80 \
        -p 8013:22 \
        --name gitlab \
        --restart always \
        --hostname gitlab.example.com \
        -v ${VOLUME}/gitlab/config:/etc/gitlab \
        -v ${VOLUME}/gitlab/logs:/var/log/gitlab \
        -v ${VOLUME}/gitlab/data:/var/opt/gitlab \
        gitlab/gitlab-ce:latest"
    docker_exec $DOCKER_CMD
}

portainer () {
    # 创建docker容器管理平台
    DOCKER_CMD="docker run -d \
        -p 8015:9000 \
        --name portainer \
        --restart always \
        -v /var/run/docker.sock:/var/run/docker.sock \
        -v ${VOLUME}/portainer/data:/data \
        portainer/portainer"
    docker_exec $DOCKER_CMD
}

seafile () {
    # 创建私云网盘
    DOCKER_CMD="docker run -d \
        -p 8019:80 \
        -p 8020:443 \
        --name seafile \
        -e SEAFILE_SERVER_HOSTNAME=myseafile.com \
        -e SEAFILE_ADMIN_EMAIL=admin@qq.com \
        -e SEAFILE_ADMIN_PASSWORD=secret20 \
        -v ${VOLUME}/seafile:/shared \
        seafileltd/seafile:latest"
    docker_exec $DOCKER_CMD
}

ubuntu_vnc () {
    # 创建镜像
    DOCKER_CMD="docker run -d \
        -p 8021:80 \
        -p 8022:5900 \
        --name ubuntu_vnc \
        -e VNC_PASSWORD=secret20 \
        -e HTTP_PASSWORD=secret20 \
        dorowu/ubuntu-desktop-lxde-vnc"
        # 可以使用参数调整屏幕分辨率 -e RESOLUTION=1366x768 \
    docker_exec $DOCKER_CMD
}

qbittorrent () {
    DOCKER_CMD="docker run -d \
        --name=qbittorrent \
        -e PUID=1000 \
        -e PGID=1000 \
        -e TZ=Europe/London \
        -e UMASK_SET=022 \
        -e WEBUI_PORT=7070 \
        -p 6881:6881 \
        -p 6881:6881/udp \
        -p 7070:7070 \
        -v ${VOLUME}/qbittorrent/config:/config \
        -v ${VOLUME}/qbittorrent/downloads:/downloads \
        --restart unless-stopped \
        linuxserver/qbittorrent"
    docker_exec $DOCKER_CMD
}

jellyfin () {
    DOCKER_CMD="docker run -d \
        -p 8096:8096 \
        --name jellyfin \
        -v ${VOLUME}/jellyfin/config:/config \
        -v ${VOLUME}/jellyfin/videos:/videos \
        --restart=always \
        jellyfin/jellyfin:latest"
    docker_exec $DOCKER_CMD
}

transmission () {
    DOCKER_CMD="docker run -d \
        --name=transmission \
        -e PUID=1000 \
        -e PGID=1000 \
        -e TZ=Europe/London \
        -e TRANSMISSION_WEB_HOME=/combustion-release/ \
        -e USER=origin \
        -e PASS=123456 \
        -p 9091:9091 \
        -p 51413:51413 \
        -p 51413:51413/udp \
        -v ${VOLUME}/transmission/config:/config \
        -v ${VOLUME}/transmission/downloads:/downloads \
        -v ${VOLUME}/transmission/watch:/watch \
        --restart unless-stopped \
        linuxserver/transmission"
    docker_exec $DOCKER_CMD
}

rutorrent () {
    DOCKER_CMD="docker run -d \
        --name=rutorrent \
        -e PUID=1000 \
        -e PGID=1000 \
        -p 8031:80 \
        -p 5000:5000 \
        -p 51414:51413 \
        -p 6881:6881/udp \
        -v ${VOLUME}/rutorrent/config:/config \
        -v ${VOLUME}/rutorrent/downloads:/downloads \
        --restart unless-stopped \
        linuxserver/rutorrent"
    docker_exec $DOCKER_CMD
}

openresty () {
    cp -r ./openresty ${VOLUME}
    DOCKER_CMD="docker run -d \
        --name openresty \
        -p 8282:80 \
        -v ${VOLUME}/openresty/conf.d:/etc/nginx/conf.d \
        -v ${VOLUME}/openresty/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf \
        openresty/openresty:alpine"
    docker_exec $DOCKER_CMD
}

phpredisadmin () {
    DOCKER_CMD="docker run -d \
        -p 8984:80 \
        --name phpredisadmin \
        -e REDIS_1_HOST=10.2.2.5 \
        -e REDIS_1_NAME=MyRedis \
        erikdubbelboer/phpredisadmin"
    docker_exec $DOCKER_CMD
}

# vpn () {
#     mkdir -p ${VOLUME}/vpn
#     echo 'VPN_IPSEC_PSK=ipsec_psk_123456' >> ${VOLUME}/vpn/vpn.env
#     echo 'VPN_USER=bigpower' >> ${VOLUME}/vpn/vpn.env
#     echo 'VPN_PASSWORD=passwd123456' >> ${VOLUME}/vpn/vpn.env
#     echo 'VPN_SETUP_IKEV2=yes' >> ${VOLUME}/vpn/vpn.env
#     DOCKER_CMD="docker run -d \
#         --name vpn \
#         --env-file ${VOLUME}/vpn/vpn.env \
#         -v ikev2-vpn-data:/etc/ipsec.d \
#         -p 500:500/udp \
#         -p 4500:4500/udp \
#         --privileged \
#         --restart=always \
#         hwdsl2/ipsec-vpn-server"
#     docker_exec $DOCKER_CMD
# }

motioneye () {
    machine="amd64"
    if [ -n "$( machine )" ]; then
        machine="armhf"
    fi
    DOCKER_CMD="docker run -d \
        -p 8765:8765 \
        --name motioneye \
        --hostname="motioneye" \
        -v /etc/localtime:/etc/localtime:ro \
        -v /home/block/motioneye/etc/motioneye:/etc/motioneye \
        -v /home/block/motioneye/file:/var/lib/motioneye \
        --detach=true \
        --device=/dev/video1 \
        --restart=always \
        ccrisan/motioneye:master-${machine}"
    docker_exec $DOCKER_CMD
}

proxy_pool () {
    DOCKER_CMD="docker run -d --network denet --ip 10.2.2.7 \
        -p 5010:5010 \
        --name proxy_pool \
        --env DB_CONN=redis://10.2.2.5:6379 \
        jhao104/proxy_pool:latest"
    docker_exec $DOCKER_CMD
}

samba () {
    DOCKER_CMD="docker run -itd \
        -p 445:445 \
        --name samba \
        -v ${VOLUME}/samba:/mount \
        dperson/samba -u 'user;password' -s 'Downloads;/mount/;yes;no;no;all;user'"
    docker_exec $DOCKER_CMD
}

screego () {
    EXTERNAL_IP=`curl 'https://api.ipify.org'`
    DOCKER_CMD="docker run -d \
        --net=host \
        --name screego \
        -e SCREEGO_EXTERNAL_IP=$EXTERNAL_IP \
        --restart always \
        screego/server:1.5.1"
    docker_exec $DOCKER_CMD
}

jenkins () {
    DOCKER_CMD="docker run -d \
	--name jenkins \
        -p 8080:8080 \
        -p 50000:50000 \
        jenkins/jenkins"
    docker_exec $DOCKER_CMD
}

showdoc () {
    DOCKER_CMD="docker run -d \
        -p 4999:80 \
        --name showdoc \
        --user=root \
        --privileged=true \
        registry.cn-shenzhen.aliyuncs.com/star7th/showdoc"
    docker_exec $DOCKER_CMD
}

sshwifty () {
    openssl req -newkey rsa:4096 -nodes -keyout domain.key -x509 -days 90 -out domain.crt
    docker run --detach \
        --restart always \
        --publish 8182:8182 \
        --env SSHWIFTY_DOCKER_TLSCERT="$(cat domain.crt)" \
        --env SSHWIFTY_DOCKER_TLSCERTKEY="$(cat domain.key)" \
        --name sshwifty \
        niruix/sshwifty:latest
}

